package com.farm.controller;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.TimeZone;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.farm.service.TimeAddressService;
import com.farm.utils_all.HUtil;

@Controller
public class TimeAddressController {
	@Autowired
	private TimeAddressService timeAddressService;
	
	//查询会议详情
		@ResponseBody
		@RequestMapping("/selectTimeAddress.do")
		public Map articleArray(@RequestParam Map<String,Object> map,HttpServletRequest request) {
			 List<Map<String, Object>> selectTimeAddress = timeAddressService.selectTimeAddress(map);
			 for (Map<String, Object> map2 : selectTimeAddress) {
				 if(map2.get("f_banner")!=null&&!"".equals(map2.get("f_banner"))) {//判断图片是否为空,不为空就查询图片
						String strt = map2.get("f_banner").toString();//获取文章表t_show字段内容
						String[] split = strt.split(",");//通过分割split把String转换数组  方便统一图片查询
						Map<String, Object> putInMap = HUtil.putInMap("list",split);//把数组存入putInMap
						map2.put("imgall",putInMap);//将此putInMap存入从数据库获取到的数据中
					}
					SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
					sdf.setTimeZone(TimeZone.getTimeZone("GMT+08"));
				    String format = sdf.format(new Date(Long.valueOf(map2.get("f_start_time")+"000"))); 
				    String formattwo = sdf.format(new Date(Long.valueOf(map2.get("f_end_time")+"000")));
				    map2.put("f_start_time", format);
				    map2.put("f_end_time", formattwo);
				}
			 return HUtil.putInMap("info", selectTimeAddress);
		} 

}
